import tabs from "@/store/tabs";
export default {
    state:{
        //菜单数据
        menuData:[
            {
                path: "/home",
                icon:"el-icon-s-platform",
                title:"首页",
                name:"home"
            },
            {
                path: "/user",
                icon:"el-icon-s-platform",
                title:"用户管理",
                name:"user"
            },
            {
                path: "/goods",
                icon:"el-icon-s-platform",
                title:"商品管理",
                name:"goods",
                children:[
                    {
                        path: "/goodType",
                        icon:"el-icon-s-platform",
                        title:"商品类型管理",
                        name:"goodType"
                    },
                    {
                        path: "/goodBrand",
                        icon:"el-icon-s-platform",
                        title:"商品品牌管理",
                        name:"goodBrand"
                    },
                    {
                        path: "/goodInfo",
                        icon:"el-icon-s-platform",
                        title:"商品信息管理",
                        name:"goodInfo"
                    }
                ]
            },
            {
                path: "/tweets",
                icon:"el-icon-s-platform",
                title:"推文管理",
                name:"tweets",
                children: [
                    {
                        path: "/tweetsChannel",
                        icon:"el-icon-s-platform",
                        title:"频道管理",
                        name:"tweetsChannel"
                    },
                    {
                        path: "/tweetsArticle",
                        icon:"el-icon-s-platform",
                        title:"文章管理",
                        name:"tweetsArticle"
                    }
                ]
            },
            {
                path: "/quote",
                icon:"el-icon-s-platform",
                title:"报价管理",
                name:"quote",
                children: [
                    {
                        path: "/quoteBudget",
                        icon:"el-icon-s-platform",
                        title:"预算管理",
                        name:"quoteBudget"
                    },
                    {
                        path: "/quotePrecept",
                        icon:"el-icon-s-platform",
                        title:"方案管理",
                        name: "quotePrecept"
                    },
                    {
                        path: "/quotePreceptFacility",
                        icon:"el-icon-s-platform",
                        title:"方案设备管理",
                        name:"quotePreceptFacility"
                    }
                ]
            }
        ]
    },
    mutations:{
        //获取tabs
        getTabs(state){
            let tabs=sessionStorage.getItem('tabsList')
            if(tabs){
                state.editableTabsValue=JSON.parse(tabs)
            }
        },
        //设置当前激活的选项卡
        setActiveTabs(state,val){
            state.editableTabsValue=val
        },
        clickMenu(state,val){
            //1.判断当前选中菜单是否在tabs里面
            let res=state.tabs.editableTabs.findIndex(item=>item.name===val.name)
            //2.如果不存在，组织tabs数据，存放到tabs的editableTabs里面
            if(res===-1){
                let tab={}
                tab.title=val.title
                tab.name=val.name
                state.tabs.editableTabs.push(tab)
            }
            //3.设置当前选中的选项卡
            state.tabs.editableTabsValue=val.name
            //4.把选中的选项卡存放到sessionStroge里面
            sessionStorage.setItem("tabsList",JSON.stringify(state.tabs.editableTabs))
        }
    },
    actions:{

    },
    modules:{
        tabs
    }
}
